package org.javaweb.cms_web.config;

import org.javaweb.cms_web.interceptor.LoginTicketInterceptor;
import org.javaweb.cms_web.interceptor.RoleBasedAccessInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import javax.annotation.Resource;

@Configuration
public class WebMvcConfig implements WebMvcConfigurer {
    @Resource
    private LoginTicketInterceptor loginTicketInterceptor;
    @Resource
    private RoleBasedAccessInterceptor roleBasedAccessInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(loginTicketInterceptor)
                .excludePathPatterns("/login", "/register", "/error", "/teammember-register");
        registry.addInterceptor(roleBasedAccessInterceptor)
                .excludePathPatterns("/login", "/register", "/logout", "/error", "/teammember-register", "/viewTeams", "/retrieve-password",
                        "/accountRegister", "/teamDetails/*", "/infoBrowse", "/accountRegister", "/ViewFeedbackController", "/SubmitFeedbackController", "/ViewReplyController",
                        "/articles/list/*", "/achievements/list/*", "/submitRegistration", "/achievements/*/*", "/articles/*/*", "/download/*", "/download"
                        , "/application-check", "/userProfile", "/dashboard","/interactiveFeature","/viewTeams/*/*","/articles/*","/normalUserDashboard");
    }
}